#ifndef _FGLYPHMAP_H_
#define _FGLYPHMAP_H_

#include "FGlyphPage.h"

namespace Font
{

	struct GlyphEntry;

	class GlyphMap
	{
	
	public:
	
		GlyphMap(Library* a_Library, FaceHandle* a_Owner);
		~GlyphMap();

		GlyphPage* GetPage(int a_Index);

		void PackGlyphs(const std::vector<Glyph*>& a_Glyphs, unsigned int a_MinLevel, bool a_Paging = true);

		void SetDefault(wchar_t a_Character);

		GlyphEntry* GetGlyphEntry(wchar_t a_Character);
		Glyph* GetGlyph(wchar_t a_Character);

		FaceHandle* GetFont();
	
	protected:

		GlyphEntry* _BuildEntry(Glyph* a_Glyph, tb::Pos2& a_Position, tb::Pos2& a_Dimensions);

		int m_CursorX, m_CursorY;

		FaceHandle* m_Owner;

		tb::Vec2 m_Multiplier;

		std::vector<GlyphPage*> m_Pages;

		std::vector<GlyphEntry*> m_Entries;
		std::map<wchar_t, GlyphEntry*> m_EntriesByGlyph;
		GlyphEntry* m_EntryDefault;

		Library* m_Library;
	
	}; // class GlyphMap

}; // namespace Font
	
#endif